﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Windows.Forms;
using TCDL.GLOBAL;
namespace TCDL.DAO
{
    class Connection
    {
        SqlConnection _connection = new SqlConnection(User.strConnect);

        public void excute(String ten_pr,List <gConnect> arrob)
        {
            _connection.Open();
            SqlTransaction _trans = _connection.BeginTransaction();
            SqlCommand command = new SqlCommand();
            command.Connection = _connection;
            command.Transaction = _trans;
            command.CommandText = ten_pr;
            command.CommandType = CommandType.StoredProcedure;
            
            for (int i = 0; i < arrob.Count; i++)
            {
                command.Parameters.Add(new SqlParameter(arrob[i].Str, arrob[i].Obj));
            }
            command.ExecuteNonQuery();
            _trans.Commit();

            _connection.Close();
        }
    }
}
